package apps.MyJMRI;
import jmri.DccThrottle;
import java.lang.Thread;

public class myWorker extends Thread
{
	static float speedIncrement = 0.01f ;
	static int sleepTime = 50;
	int WkDir = 1; /* +1/-1 depending on direction */
	DccThrottle throttle;    

	myWorker(int dir, DccThrottle throttle)
	{
		WkDir = dir;
		this.throttle = throttle;
		start();
	}

	public void run()
	{
		try
		{
			while(true)
			{
				float sp = throttle.getSpeedSetting() + WkDir * speedIncrement;
				if (sp<0) sp = 0;
				if (sp>1) sp = 1;
				throttle.setSpeedSetting( sp );
				Thread.sleep(sleepTime);
			}
		}
		catch (InterruptedException e)
		{
			this.interrupt();
		}
	}	
}
